<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
    <title>Add RatePlan</title>
    <link type="text/css" href="${contextPath}/static/style/global.css" rel="stylesheet"/>
    <script type="text/javascript" src="${contextPath}/static/script/jquery/jquery-1.4.2.js"></script>
    <script type="text/javascript" src="${contextPath}/static/script/jquery/jquery.validate.js"></script>
    <script type="text/javascript" language="JavaScript">
        function create_rate_plan() {
            $("input:checkbox").eq(0).val($("input:checkbox").eq(0).attr("checked"));
            $("#mainForm").attr("action", "./update.dhtml");
            $("#mainForm").submit();
        }

        $(function() {
            $("#mainForm").validate();
        });
        function clean_error(obj) {
            obj.parent().children("span:eq(0)").remove();
        }
    </script>
</head>
<body>
<div class="main">
    <form id="mainForm">
        <fieldset>
            <legend>
                <span class="title">Free Meal Strategy</span>
            </legend>
            <table class="table_list">
                <tr>
                    <input type="hidden" value="${freeMealStrategy.id}" name="freeMealStrategy.id"/>
                    <td class="key" width="150">Channel Pattern:</td>
                    <td class="value"><input type="text" class="required" value="${freeMealStrategy.channelPattern}" name="freeMealStrategy.channelPattern"/></td>
                </tr>
                <tr>
                    <td class="key">Hotel Pattern:</td>
                    <td class="value"><input value="${freeMealStrategy.hotelPattern}" name="freeMealStrategy.hotelPattern" cols="80"/></td>
                </tr>
                <tr>
                    <td class="key">Rate Plan Pattern:</td>
                    <td class="value"><input value="${freeMealStrategy.ratePlanPattern}" name="freeMealStrategy.ratePlanPattern" cols="80"/></td>
                </tr>
                <tr>
                    <td class="key">Room Type Pattern:</td>
                    <td class="value"><input value="${freeMealStrategy.roomTypePattern}" name="freeMealStrategy.roomTypePattern" cols="80"/></td>
                </tr>
                <tr>
                    <td class="key">Free Meal Type:</td>
                    <td class="value">
                        <select class="select" name="freeMealStrategy.type">
                            <s:iterator value="@com.derbysoft.remote.dswitch.hotel.constants.FreeMealType@values()"
                                        id="freeMealType">
                                <option
                                        <s:if test="freeMealStrategy.type==#freeMealType">
                                            selected="selected"
                                        </s:if>
                                        value="${freeMealType}">${freeMealType}</option>
                            </s:iterator>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="key">FreeMealUnit:</td>
                    <td class="value">
                        <select class="select" name="freeMealStrategy.unit">
                            <s:iterator value="@com.derbysoft.remote.dswitch.hotel.constants.FreeMealUnit@values()"
                                        id="freeMealUnit">
                                <option
                                        <s:if test="freeMealStrategy.unit==#freeMealUnit">
                                            selected="selected"
                                        </s:if>
                                        value="${freeMealUnit}">${freeMealUnit}</option>
                            </s:iterator>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="key">Quantity:</td>
                    <td class="value"><input type="text" maxlength="5" size="5" class="longText" value="${freeMealStrategy.quantity}" name="freeMealStrategy.quantity"/></td>
                </tr>
                <tr>
                    <td class="key">Description:</td>
                    <td class="value"><input type="text" class="longText" maxlength="255" size="100" value="${freeMealStrategy.description}"
                                             name="freeMealStrategy.description"/></td>
                </tr>
            </table>
        </fieldset>
        <input type="button" value="Save" class="common_button" onclick="create_rate_plan();"/>
        <input type="button" value="Back" class="common_button" onclick="window.location.href='list.dhtml'"/>
        <s:if test="inputError!=null">
            <span style="color: #ff0000">${inputError}</span>
        </s:if>
    </form>
</div>

</body>
</html>